﻿#region Using Statements
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Graphics.PackedVector;
#endregion

namespace GameBase.Particles
{
    /// <summary>
    /// Describes a custom vertex format structure that contains 3D particle data.
    /// </summary>
    internal struct Particle3D : IVertexType
    {
        /// <summary>
        /// Starting position of the particle.
        /// </summary>
        public Vector3 Position;

        /// <summary>
        /// Corner this vertex represents within the particle quad.
        /// </summary>
        public Short2 Corner;

        /// <summary>
        /// Starting velocity of the particle.
        /// </summary>
        public Vector3 Velocity;

        /// <summary>
        /// Moment in time at which the particle was created.
        /// </summary>
        public float TimeStamp;

        /// <summary>
        /// Randomness of every particle.
        /// <para>R -> duration; G -> size; B -> rotation; A -> color;</para>
        /// </summary>
        public Color Random;

        /// <summary>
        /// Size of the vertex structure.
        /// </summary>
        public const int Size = 36;

        /// <summary>
        /// Vertex declaration, which defines per-vertex data.
        /// </summary>
        public static readonly VertexDeclaration VertexDeclaration = new VertexDeclaration
        (
            new VertexElement(0, VertexElementFormat.Vector3, VertexElementUsage.Position, 0),
            new VertexElement(12, VertexElementFormat.Short2, VertexElementUsage.Color, 0),
            new VertexElement(16, VertexElementFormat.Vector3, VertexElementUsage.Color, 1),
            new VertexElement(28, VertexElementFormat.Single, VertexElementUsage.Color, 2),
            new VertexElement(32, VertexElementFormat.Color, VertexElementUsage.Color, 3)
        );

        VertexDeclaration IVertexType.VertexDeclaration
        {
            get { return VertexDeclaration; }
        }
    }
}
